<template>
  <div class="list-wrapper">
    <!-- <filtrate :fetchData="fetchData" :isShow="isShow"></filtrate> -->
    <h4>教室出租数据统计</h4>
    <div class="return">
      <span class="el-icon-d-arrow-left"></span>
      <router-link to="/dashboard/classroomIncome">
        <span>返回图表</span>
      </router-link>
    </div>
		<div class="list-top">
      <div>
        <span style="margin-right:100px">教室编号：{{info.number}}</span>        
        <span>教室名称：</span>
        <span @click="goClassRoomDetail" style="cursor:pointer">{{info.name}}</span>
      </div>
			<!-- <el-button type="primary">下载</el-button> -->
		</div>
		<table class="list-table" border="0" cellspacing="0" cellpadding="0">
			<thead>
				<tr>
					<th>序号</th>
          <th>日期</th>
          <th>小时数</th>
					<th>事由</th>
          <th>租用人</th>
          <th>金额</th>
          <th>备注</th>
				</tr>
			</thead>
			<tbody>
				<tr v-for="(item,index) in list">
					<td>{{index+1}}</td>
					<td>{{item.date}}</td>
          <td>{{item.hourage}}</td>
          <td>{{item.excuse}}</td>
          <td>{{item.lessee}}</td>
          <td>{{item.money}}</td>
          <td>{{item.comments}}</td>
				</tr>
			</tbody>
		</table>
		<div class="pagination">
      <el-pagination v-if="list.length" @current-change="handleCurrentChange" :current-page="page" :page-size="10" layout="total, prev, pager, next, jumper" :total="total">
      </el-pagination>
      <div class="mess" v-if="!list.length">暂无数据</div>
    </div>
	</div>
</template>
<script>
import filtrate from "../filtrate";

export default {
  data() {
    return {
      isShow: true,
      page: 1,
      total: 0,
      id: "",
      filData: {},
      info: {},
      list: [],
      classRoomId: ""
    };
  },
  components: {
    filtrate
  },
  methods: {
    fetchData(time, type) {
      let data = {
        time: time ? time : "",
        courseType: type ? type : "",
        classroom: this.id,
        page: this.page
      };
      this.apiPost("Dashboard/classroomIncomeDetail", data).then(res => {
        this.info = res.info;
        this.list = res.list;
        this.classRoomId = res.info.id;
        this.total = res.total;
      });
    },
    handleCurrentChange(val) {
      this.page = val;
      if (this.filData) {
        this.fetchData(this.filData.time, this.filData.courseType);
      } else {
        this.fetchData();
      }
    },
    goClassRoomDetail() {
      window.open(SITE+"operate/assets/facilities/classroomDetail/"+this.classRoomId);
    },
  },
  created() {
    this.id = this.$route.params.id;
    this.filData = Lockr.get("filData");
    if (this.filData) {
      this.fetchData(this.filData.time, this.filData.courseType);
    } else {
      this.fetchData();
    }
  }
};
</script>
<style lang="css" scoped>
.container {
  box-sizing: border-box;
  width: 100%;
  background: #ffffff;
  min-height: 100%;
  font-size: 14px;
  overflow: hidden;
}
.list-wrapper > h4 {
  text-align: center;
  padding-top: 20px;
}
.el-icon-d-arrow-left {
  margin: 0 5px 10px 0;
  font-size: 14px;
}
.return{
  padding-left: 20px;
}
.return a{
  color: #333;
}
.list-top{
  padding: 0 20px 10px;
}
.pagination {
  text-align: center;
  margin-top: 30px;
}
.mess {
  color: #666;
}
</style>
